//
//  PHStatusListViewModel.swift
//  PHWeibo
//
//  Created by 潘荟 on 16/7/23.
//  Copyright © 2016年 BAT. All rights reserved.
//

import UIKit

class PHStatusListViewModel: NSObject {

    
    //全局的模型数组
    lazy var statusList: [PHStatusViewModel] = [PHStatusViewModel]()
    
    
}
// MARK: - 微博首页
extension PHStatusListViewModel {
    func getHomeData(isFinish :(isSucc : Bool)->()) {
        PHNetworktools.sharedTools.getHomeData({ (response) -> () in
            
            print(response)
            guard let res = response?["statuses"] as? [[String : AnyObject]] else {
                isFinish(isSucc: false)
                return
            }
            
            var tempArray :[PHStatusViewModel] = [PHStatusViewModel]()
            
            //遍历
            for dic in res {
                let status = PHStatus(dict: dic)
                
                let statusViewModel = PHStatusViewModel(status :status)
                
                tempArray.append(statusViewModel)
            }
            
            self.statusList = tempArray
            
            isFinish(isSucc: true)
            
            }) { (error) -> () in
                isFinish(isSucc: false)
        }
    }
}